/*
 * Copyright (c) 2002-2004, xRhino, Inc.
 *
 * This library is free software; you can redistribute and/or modify
 * it under the terms of the dual license distributed with this source
 * package (a combined Trolltech QPL/GPL-compatible license)
 *
 * Under this dual license scheme, a separate license is available for use of 
 * this code with a proprietary (closed) system. For more information on the 
 * license, please see the LICENSE file distributed with this source package.
 */
#include "SugLength.h"

unsigned short SugLength::getUnitType()
{
   return mUnitType;
}

SugRealType SugLength::getValue()
{
   return mValue;
}

SugRealType SugLength::getValueInSpecifiedUnits()
{
   return mValueInSpecifiedUnits;
}

char* SugLength::getValueAsString()
{
   return mValueAsString;
}

void SugLength::newValueSpecifiedUnits(unsigned short unitType, SugRealType valueInSpecifiedUnits)
{
   mValue = valueInSpecifiedUnits;
   mValueInSpecifiedUnits = valueInSpecifiedUnits;
   mUnitType = unitType; 
}

void SugLength::convertToSpecifiedUnits(unsigned short unitType)
{
   SugRealType tempValue;

   // First let's convert to px, which is our common format

   switch (mUnitType) {
      case (SVG_LENGTHTYPE_PT): tempValue = 1.25 * mValue;
      case (SVG_LENGTHTYPE_PC): tempValue = 15.0 * mValue;
      case (SVG_LENGTHTYPE_MM): tempValue = 3.543307 * mValue;
      case (SVG_LENGTHTYPE_CM): tempValue = 35.43307 * mValue;
      case (SVG_LENGTHTYPE_IN): tempValue = 90.0 * mValue;
      default: tempValue = mValue; break;
   }

   switch (unitType) {
      case (SVG_LENGTHTYPE_PT): mValueInSpecifiedUnits = tempValue / 1.25;
      case (SVG_LENGTHTYPE_PC): mValueInSpecifiedUnits = tempValue / 15.0;
      case (SVG_LENGTHTYPE_MM): mValueInSpecifiedUnits = tempValue / 3.543307;
      case (SVG_LENGTHTYPE_CM): mValueInSpecifiedUnits = tempValue / 35.43307;
      case (SVG_LENGTHTYPE_IN): mValueInSpecifiedUnits = tempValue / 90.0;
      default: mValueInSpecifiedUnits = tempValue; break;
   }
}

SugLength::SugLength()
{
}

SugLength::~SugLength()
{
}

